<template>
  <el-dialog
          :title="titleName"
          width="90%"
          :visible.sync="dialogVisible"
          :append-to-body="true"
          @close="$emit('update:visible',false)">
    <div class="previewlog">
      <div id="printpage">
        <iframe id="show-iframe" frameborder=0 name="showHere" scrolling=auto :src="printUrl"
                class="iframeBoxLine"></iframe>
      </div>
    </div>
  </el-dialog>
</template>

<script>
  export default {
    name: 'print',
    props: ['visible', 'studentInfo', 'type'], // type 1问卷 2通知
    watch: {
      visible () {
        this.dialogVisible = this.visible
        if (this.visible) {
          this.titleName =  `预览打印【${this.studentInfo.student.name}】`
          this.printUrl = `${this.$BASE_URL}/index.html?id=${this.studentInfo.id}&type=${this.type}`
        } else {
          this.printUrl = ''
        }
      }
    },
    data () {
      return {
        dialogVisible: this.visible,
        titleName: '',
        printUrl: ''
      }
    },
    created () {

    },
    methods: {}
  }
</script>
<style>
.iframeBoxLine{
  width: 100%;
}
</style>
